package com.settlement.system.common.util.common;


import com.settlement.system.model.entity.common.TblOrderAuditCategory;
import com.settlement.system.model.entity.common.TblOrderAuditReport;
import com.settlement.system.parse.formula.MultiEqualsCalculator;
import com.settlement.system.parse.formula.OrderPlaceHoldParse;

import java.util.List;
import java.util.Map;

/**
 * 订单稽核类别挑选
 *
 * @author Ximi
 * @since 2020/10/13
 */
public class OrderAuditCategoryCalculatorUtils {

    public static TblOrderAuditCategory selectCategory(TblOrderAuditReport auditReport,
                                                       Map<String, Object> params,
                                                       List<TblOrderAuditCategory> candidates) {

        OrderPlaceHoldParse placeHoldParse = new OrderPlaceHoldParse(auditReport, params);
        MultiEqualsCalculator calculator = new MultiEqualsCalculator(placeHoldParse);
        for (TblOrderAuditCategory candidate : candidates) {
            if (calculator.calculate(candidate.getDetermineCondition())) {
                return candidate;
            }
        }

        return null;
    }

}
